package com.slx.perfect_number;

public class Solution {
    public boolean checkPerfectNumber(int num) {
        if (num < 6) {
            return false;
        }

        int sum = 1;
        int sqrt = (int) Math.sqrt(num);

        for (int i = 2; i <= sqrt; i++) {
            if (num % i == 0) {
                sum += i;
                sum += num / i;
            }
        }

        return sum == num;
    }
}
